﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZdSoft.Core;
using ZdSoft.BLL;
using ZdSoft.IDAL;
using ZdSoft.Model;
using System.Web.Script.Serialization;

namespace ZdSoft.Web.OnlineStudy.Controllers
{
    public class CourseController : BaseController
    {
        [HttpGet]
        // GET: Cource
        public ViewResult Index()
        {
            IList<Course> listCourse=Container.Instance.Resolve<ICourseDAL>().GetAll();
            var query=listCourse.Take(0).Skip(10).ToList();
            ViewBag.courseCount = listCourse.Count;
            return View(query);
        }
        [HttpPost]
        public JsonResult Index(int pageSize, int pageIndex)
        {
            IList<Course> listCourse = Container.Instance.Resolve<ICourseDAL>().GetAll();
            var query = listCourse.Take(0).Skip(10).ToList();
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonStr = js.Serialize(query);
            return Json(jsonStr);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create(Course cs)
        {
            try
            {
                Container.Instance.Resolve<ICourseDAL>().Create(cs);
                return View();
            }
            catch
            {
                return View();
            }
            return View();
        }

    }
}